﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BizzUI.UserControls
{
    public partial class IconItem : UserControl
    {
        private const string treeViewRootTitle = "BizzComm Server";
        private const string workspaceTitle = "Área de trabajo";
        private const string concreteInboxTitle = "Bandejas de entradaN";
        private const string concreteOutboxTitle = "Bandejas de salidaN";
        private const string rulesTitle = "Reglas";
        private const string messageHistorytitle = "Histórico de mensajes";
        private const string configSectionTitle = "Configuración";
        private const string inboxTypetitle = "Tipos de bandeja de entradaN";
        private const string outboxTypetitle = "Tipos de bandeja de salidaN";
        private const string globalConfigTitle = "Configuraciones globales";
        private const string appLogTitle = "Logs de auditoría";
        
        private TreeNode _node { get; set; }
        public IconItem(TreeNode node)
        {
            InitializeComponent();
            _node = node;
            //iconText.Text = _node.Text;
            
            iconText.Lines = convertToMultiLine(_node.Text);
            initImages();
        }

        private void initImages()
        {
            string caseText = _node.Text;
            if (_node.Tag != null) caseText = _node.Parent.Text + "N";
            
            switch (caseText)
            {
                case configSectionTitle: imageIcon.Image = global::BizzUI.Properties.Resources.config; break;
                case inboxTypetitle: imageIcon.Image = global::BizzUI.Properties.Resources.Provider.ToBitmap(); break;
                case outboxTypetitle: imageIcon.Image = global::BizzUI.Properties.Resources.Provider.ToBitmap(); break;
                case concreteInboxTitle: imageIcon.Image = global::BizzUI.Properties.Resources.inboxIcon; break;
                case concreteOutboxTitle: imageIcon.Image = global::BizzUI.Properties.Resources.outboxIcon; break;
                case appLogTitle: imageIcon.Image = global::BizzUI.Properties.Resources.AuditLog.ToBitmap(); break;

                 default: imageIcon.Image = global::BizzUI.Properties.Resources.folder; break;
            }
                

            
            
        }

        private string[] convertToMultiLine(string text)
        {
                string[] multiText = text.Split(' ');
                string line = "";
                if (multiText.Length != 1)
                {
                    for (int i = 0; i < multiText.Length - 1; i++)
                    {
                        line += multiText[i] + " ";
                    }
                    return new string[] { line, multiText[multiText.Length - 1] };
                }
                else
                    return multiText;
        }


    }
}
